<template>
	<view class="uni-dialog">

		<view class="cardBody">
			<uni-icons type="closeempty" class="floatR" @click="closeOpen" />
			<view class="cardHeader">
				<image :src='url'></image>
				<view class="textCenter">
					<view class="title">￥12</view>
					<view class='text'>番茄炒蛋</view>
					<text>番茄炒蛋</text>
				</view>
			</view>
			<view class="cardCenter">
				<view class="tasteCard">
					<view class="tasteTitle">
						<text>口味</text>
						<view class="right">
							<image src="http://localhost:8080/static/deleteButton.png" @click="deleteFun" />
							<view>{{value}}</view>
							<image src="http://localhost:8080/static/addButton.png" @click="addFun"></image>
						</view>
					</view>
					<view class="tasteMain">
						<view class="tasteButton" v-for="(item,index) in taste" :key="index">
							<button @click="clickButton(item,index)" :class="index==active?'colorH':''">{{item}}</button>
						</view>
					</view>
				</view>
			</view>
		</view>
		<button @click="retunFunc" class="colorH">加入购物车</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '红烧牛肉',
				introduce: '150牛肉',
				taste: ["微辣", "不辣", "微微辣"],
				number: 50,
				url: 'http://localhost:8080/static/lbt3.png',
				value: 0,
				active: 0
			};
		},
		methods: {
			// 减少
			deleteFun() {
				if (this.value == 0) {
					return
				} else {
					this.value -= 1
				}
			},
			// 增加
			addFun() {
				this.value += 1
			},
			// 按钮点击
			clickButton(item, index) {
				this.active = index
			},
			// 加入购物车
			retunFunc() {
				this.$emit('closeDilog', true)
			},
			// 关闭
			closeOpen() {
				this.$emit('closeDilog', true)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uni-dialog {
		padding: 25rpx 40rpx;
		height: 100%;

		.colorH {
			color: #fff;
			background: #FF922C !important;
			width: 100%;
			border-radius: 40rpx;

		}

		.cardBody {
			height: calc(100% - 180rpx);
			width: 100%;

			.cardHeader {
				dispaly: flex;
				flex-direction: row;
				// justify-content: space-between;
				border-bottom: 1px solid #eaeaea;
				padding-bottom: 25rpx;

				image {
					width: 144rpx;
					height: 144rpx;
					border-radius: 10rpx;
				}

				.textCenter {
					height: 144rpx;
					padding-left: 25rpx;

					.title {
						text-align: left;
						font-size: 16px;
						font-weight: 700;
						color: #EC3636;
					}

					.text {
						text-align: left;
						font-size: 14px;
						font-weight: 500;
						// padding: 0;
						// height: 50rpx
					}

					text {
						font-size: 10px;
						color: #666666;
					}
				}
			}

			// background:blue
		}
	}

	.floatR {
		// float:right;
		position: absolute;
		font-size: 20px !important;
		z-index: 1500;
		right: 0px;
		top: -20rpx;
		color: #666666 !important;
	}

	.tasteCard {
		padding: 10rpx 40rpx;

		.tasteTitle {
			// font-size: 20rpx;
			margin-bottom: 20rpx;
			display: flex;
			flex-direction: row;
			justify-content: space-between;

			.right {
				display: flex;
				flex-direction: row;
				justify-content: space-between;
				width: 180rpx;
				height: 50rpx;

				image {
					width: 40rpx;
					height: 40rpx;
					cursor: pointer;
					margin-top: 8rpx;
				}

				view {
					line-height: 40rpx;
					margin-top: 8rpx;
					font-size: 16px;
					// flex:2
				}
			}
		}

		.tasteMain {
			display: flex;
			flex-direction: row;
			// justify-content: space-between;
		}

		.tasteButton {
			width: 100rpx;
			margin-right: 15rpx;

			button {
				height: 60rpx;
				border-radius: 15rpx;
				line-height: 60rpx;
				padding: 0 20rpx;
				font-size: 14px;
				white-space: nowrap;
				background: #EEEEEE;
			}
		}
	}
</style>
